package com.yhy.wxzn.wcs.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yhy.wxzn.wcs.entity.WcsInboundConfig;
import com.yhy.wxzn.wcs.entity.WcsOutboundConfig;
import com.yhy.wxzn.wcs.entity.WcsOutboundDetail;
import com.yhy.wxzn.wcs.mapper.WcsOutboundConfigMapper;
import com.yhy.wxzn.wcs.service.IWcsOutboundConfigService;
import com.yhy.wxzn.wcs.service.IWcsOutboundDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description: 出库配置
 * @Author: jeecg-boot
 * @Date:   2023-11-08
 * @Version: V1.0
 */
@Service("WcsOutboundConfigServiceImpl")
public class WcsOutboundConfigServiceImpl extends ServiceImpl<WcsOutboundConfigMapper, WcsOutboundConfig> implements IWcsOutboundConfigService {

    @Autowired
    private IWcsOutboundDetailService outboundDetailService;

    @Override
    public void removeInboundConfigBatch(List<String> outboundIds) {
        LambdaQueryWrapper<WcsOutboundDetail> wrapper = new LambdaQueryWrapper<>();
        wrapper.in(WcsOutboundDetail::getOutboundId,outboundIds);
        outboundDetailService.remove(wrapper);
        this.removeByIds(outboundIds);
    }

    @Override
    public WcsOutboundConfig getByPortCode(String portCode) {
        LambdaQueryWrapper<WcsOutboundConfig> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(WcsOutboundConfig::getCode,portCode);
        return getOne(wrapper);
    }
}
